package com.ciaojian.client.controller;

import com.ciaojian.client.model.param.BusinessCutParam;
import com.ciaojian.core.base.annotation.ApiIdempotent;
import com.ciaojian.core.model.BusinessCut;
import com.ciaojian.core.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author Atlakyn
 */
@Api(tags = "企业剪")
@RestController
@RequestMapping("/business-cut")
public class BusinessCutController {

    @ApiOperation("提交企业剪")
//    @ApiIdempotent
    @PostMapping("/submit")
    public Result submit(@RequestBody @Validated BusinessCutParam param) {
        BusinessCut businessCut = new BusinessCut();
        businessCut.setCreateTime(new Date());
        BeanUtils.copyProperties(param, businessCut);
        return Result.save(businessCut.insert());
    }
}